<html>
<head>
  <meta HTTP-EQUIV="Content-Type" CONTENT="text/html;charset=ISO-8859-1">
  <title>Contents.m</title>
<link rel="stylesheet" type="text/css" href="../stpr.css">
</head>
<body>
<table  border=0 width="100%" cellpadding=0 cellspacing=0><tr valign="baseline">
<td valign="baseline" class="function"><b class="function">CMEANS</b>
<td valign="baseline" align="right" class="function"><a href="../probab/index.html" target="mdsdir"><img border = 0 src="../up.gif"></a></table>
  <p><b>K-means clustering algorithm.</b></p>
  <hr>
<div class='code'><code>
<span class=help>&nbsp;</span><br>
<span class=help>&nbsp;<span class=help_field>Synopsis:</span></span><br>
<span class=help>&nbsp;&nbsp;[model,y]&nbsp;=&nbsp;cmeans(X,num_centers)</span><br>
<span class=help>&nbsp;&nbsp;[model,y]&nbsp;=&nbsp;cmeans(X,num_centers,Init_centers)</span><br>
<span class=help></span><br>
<span class=help>&nbsp;<span class=help_field>Description:</span></span><br>
<span class=help>&nbsp;&nbsp;[model,y]&nbsp;=&nbsp;cmeans(X,num_centers)&nbsp;runs&nbsp;C-means&nbsp;clustering&nbsp;</span><br>
<span class=help>&nbsp;&nbsp;&nbsp;where&nbsp;inital&nbsp;centers&nbsp;are&nbsp;randomly&nbsp;selected&nbsp;from&nbsp;the&nbsp;</span><br>
<span class=help>&nbsp;&nbsp;&nbsp;input&nbsp;vectors&nbsp;X.&nbsp;The&nbsp;output&nbsp;are&nbsp;found&nbsp;centers&nbsp;stored&nbsp;in&nbsp;</span><br>
<span class=help>&nbsp;&nbsp;&nbsp;structure&nbsp;model.</span><br>
<span class=help>&nbsp;&nbsp;&nbsp;</span><br>
<span class=help>&nbsp;&nbsp;[model,y]&nbsp;=&nbsp;cmeans(X,num_centers,Init_centers)&nbsp;uses</span><br>
<span class=help>&nbsp;&nbsp;&nbsp;init_centers&nbsp;as&nbsp;the&nbsp;starting&nbsp;point.</span><br>
<span class=help></span><br>
<span class=help>&nbsp;<span class=help_field>Input:</span></span><br>
<span class=help>&nbsp;&nbsp;X&nbsp;[dim&nbsp;x&nbsp;num_data]&nbsp;Input&nbsp;vectors.</span><br>
<span class=help>&nbsp;&nbsp;num_centers&nbsp;[1x1]&nbsp;Number&nbsp;of&nbsp;centers.</span><br>
<span class=help>&nbsp;&nbsp;Init_centers&nbsp;[1x1]&nbsp;Starting&nbsp;point&nbsp;of&nbsp;the&nbsp;algorithm.</span><br>
<span class=help>&nbsp;&nbsp;&nbsp;&nbsp;</span><br>
<span class=help>&nbsp;<span class=help_field>Output:</span></span><br>
<span class=help>&nbsp;&nbsp;model&nbsp;[struct]&nbsp;Found&nbsp;clustering:</span><br>
<span class=help>&nbsp;&nbsp;&nbsp;.X&nbsp;[dim&nbsp;x&nbsp;num_centers]&nbsp;Found&nbsp;centers.</span><br>
<span class=help></span><br>
<span class=help>&nbsp;&nbsp;&nbsp;.y&nbsp;[1&nbsp;x&nbsp;num_centers]&nbsp;Implicitly&nbsp;added&nbsp;labels&nbsp;1..num_centers.</span><br>
<span class=help>&nbsp;&nbsp;&nbsp;.t&nbsp;[1x1]&nbsp;Number&nbsp;of&nbsp;iterations.</span><br>
<span class=help>&nbsp;&nbsp;&nbsp;.MsErr&nbsp;[1xt]&nbsp;Mean-Square&nbsp;error&nbsp;at&nbsp;each&nbsp;iteration.</span><br>
<span class=help></span><br>
<span class=help>&nbsp;&nbsp;y&nbsp;[1&nbsp;x&nbsp;num_data]&nbsp;Labels&nbsp;assigned&nbsp;to&nbsp;data&nbsp;according&nbsp;to&nbsp;</span><br>
<span class=help>&nbsp;&nbsp;&nbsp;the&nbsp;nearest&nbsp;center.</span><br>
<span class=help></span><br>
<span class=help>&nbsp;<span class=help_field>Example:</span></span><br>
<span class=help>&nbsp;&nbsp;data&nbsp;=&nbsp;load('riply_trn');</span><br>
<span class=help>&nbsp;&nbsp;[model,data.y]&nbsp;=&nbsp;cmeans(&nbsp;data.X,&nbsp;4&nbsp;);</span><br>
<span class=help>&nbsp;&nbsp;figure;&nbsp;ppatterns(data);&nbsp;</span><br>
<span class=help>&nbsp;&nbsp;ppatterns(model,12);&nbsp;pboundary(&nbsp;model&nbsp;);</span><br>
<span class=help></span><br>
<span class=help>&nbsp;<span class=also_field>See also </span><span class=also></span><br>
<span class=help><span class=also>&nbsp;&nbsp;<a href = "../probab/estimation/emgmm.html" target="mdsbody">EMGMM</a>,&nbsp;<a href = "../misc/knnclass.html" target="mdsbody">KNNCLASS</a>.</span><br>
<span class=help></span><br>
</code></div>
  <hr>
  <b>Source:</b> <a href= "../probab/list/cmeans.html">cmeans.m</a>
  <p><b class="info_field">(c) </b> Statistical Pattern Recognition Toolbox, (C) 1999-2003,<br>
 Written by Vojtech Franc and Vaclav Hlavac,<br>
 <a href="http://www.cvut.cz">Czech Technical University Prague</a>,<br>
 <a href="http://www.feld.cvut.cz">Faculty of Electrical engineering</a>,<br>
 <a href="http://cmp.felk.cvut.cz">Center for Machine Perception</a><br>

  <p><b class="info_field">Modifications: </b> <br>
 18-dec-2008, VF, fix: Init_centers argument used as the initial solution<br>
 17-jun-2007, VF, renamed from kmeans to cmeans to avoid conflicts with stats toolbox<br>
 12-may-2004, VF<br>

</body>
</html>
